define(function(require, exports, module) {

    var axios = require('lib/axios/index.js');

    var ShowCode = require("components/show-code/index.js");

    var layer = require('components/layer/index.js');


    var vueApp = new Vue({
        el: '#app',
        data: {
            form: {
                "Id": 0,
                "Name": "",
                "Url": "",
                "HrefTarget": "",
                "GroupName": "",
                "GroupRemark": "",
                "DataFlag": 1
            },
            enums: {
                DataFlag: []
            },
            editor: {}
        },
        mounted: function() {

            var thisVue = this;
            thisVue.bindForm();

            var url = baseSiteUrl + "/USER/EnumConvert2";
            axios.get(url)
                .then(function(response) {
                    thisVue.enums.DataFlag = response.data;
                });
        },

        methods: {
            bindForm: function() {

                var me = this;
                var tools = require('lib/tools.js');

                var map = tools.getUrlParamsMap();


                var url = baseSiteUrl + "PageConfig/GetById";
                map.id = map.id || 0;
                url = url + "?Id=" + map.id || 0;

                axios.get(url)
                    .then(function(response) {
                        me.form = response.data;

                        if (me.form.Id == 0)
                        {
                            me.form.DataFlag = 1;
                        }
                    });
            },
            submit: function() {
                var me = this;
                var url = baseSiteUrl + "PageConfig/SaveOrUpdate";


                $.ajax({
                    type: 'POST',
                    url: url,
                    dataType: 'json',
                    data: me.form,
                    success: function(res) {
                        toastr.success('操作成功');
                        setTimeout(function() {
                            window.parent.layer.closeAll();
                            window.parent.vueApp.tableSearch();
                        }, 1000);
                    }
                })
            }
        }

    });

});